<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>后台登录-X-admin2.2</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>

    <link rel="stylesheet" type="text/css" th:href="@{/layui/dist/css/layui.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/selbbs.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/myTest.css}"/>
    <script th:src="@{/js/jquery.min.js}"></script>
    <script th:src="@{/layui/dist/layui.js}"></script>
    <!--<script th:src="@{/js/fen.js}" ></script>-->
    <script th:src="@{/js/fen2.js}"></script>

    <style media="screen" type="text/css">
        body {
            background-color: #FCFCFC;
        }

        .a1 {
            width: 96%;
            height: 20%;
            /*text-align: center;*/
            /*margin: 0px 20px 0px 20px;*/
            font-size: 14px;
            font-family: "agency fb";
            /*margin: 0px auto;*/
        }

        table.layui-form.a1 {
            /*margin-top: 30px;*/
            margin: 30px 0px 0px 30px;
        }

        .a2 {
            width: 100%;
        }

        .a3 {
            width: 6%;
            text-align: center;
        }

        .a5 {
            width: 13%;

        }

        .a4 {
            width: 96%;
            height: 20%;
            text-align: center;
            margin: 50px 20px 30px 20px;

            font-family: "agency fb";
            text-align: center;
            margin: 0px auto;
            color: #0C0C0C;
        }

        .a7 {
            text-align: center;
            margin-top: 50px;

        }

        .a8 {
            margin-right: 100px;

        }

        .a9 {
            font-size: 18px;
            font-weight: bold;
            font-family: "agency fb";
            margin-right: 100px;

        }


    </style>

</head>
<body onload="pageInfos()" class="table-bordered">

<table class="layui-table layui-form a1">
    <tr>
        <td>姓名：</td>
        <td><input type="text" name="reName" id="reName" value="" class="layui-input a2"/></td>
        <td>应聘职位：</td>
        <td><input type="text" name="posname" id="posname" value="" class="layui-input a2"/></td>
        <td>工作经验：</td>
        <td><input type="text" name="workEx" id="workEx" value="" class="layui-input a2"/></td>
        <td>简历状态：</td>
        <td>
            <!--					 lay-ignore -->
            <div class="layui-input-inline" style="display: block;">
                <div class="layui-input-block" style="margin-left: 0px;">
                    <select name="city" lay-verify="" id="resState">
                        <option value="请选择">请选择</option>
                        <option value="存档">存档</option>
                        <option value="推荐面试">推荐面试</option>
                        <option value="推荐二面">推荐二面</option>
                        <option value="推荐三面">推荐三面</option>
                        <option value="建议录用">建议录用</option>
                        <option value="录用">录用</option>
                        <option value="删除">删除</option>
                    </select>
                </div>
            </div>
        </td>
        <td>登记日期：</td>
        <td><input type="text" name="checkTime" id="checkTime" value="" class="layui-input a2"
                   style="width: 160px;height: 40px"/></td>
        <td class="a3">
            <button type="button" class="layui-btn " th:onclick="selPro()">查&nbsp;&nbsp;询</button>
        </td>
    </tr>
</table>
<div style="width:96%; margin: 20px auto;">
    <a href="/resume/dengji">
        <button type="button" class="layui-btn ">简历登记</button>
    </a>
</div>


<form>
    <table border="" class="layui-table a4 table-page">
        <tr>
            <th style="font-weight: bold; text-align: center">姓名</th>
            <th style="font-weight: bold; text-align: center">性别</th>
            <th style="font-weight: bold; text-align: center">毕业学校</th>
            <th style="font-weight: bold; text-align: center">学历</th>
            <th style="font-weight: bold; text-align: center">专业</th>
            <th style="font-weight: bold; text-align: center">应聘岗位</th>
            <th style="font-weight: bold; text-align: center">工作经验</th>
            <th style="font-weight: bold; text-align: center">登记时间</th>
            <th style="font-weight: bold; text-align: center">简历状态</th>
            <th style="font-weight: bold; text-align: center">操作</th>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </table>
</form>


<div class="icon a7">
    <button class="layui-btn" onclick="start()">首页</button>
    <button class="layui-btn  layui-icon layui-icon-prev a8" onclick="prev()"></button>

    <span class="showPage a9 page pagess">第1页/共1页</span>

    <button class="layui-btn  layui-icon layui-icon-next " onclick="next()"></button>
    <button class="layui-btn" onclick="end()">末页</button>
</div>
<br><br>
</body>

<script>
    layui.use('table', function () {
        var table = layui.table; //只有执行了这一步，部分表单元素才会自动修饰成功

        //……

        //但是，如果你的HTML是动态生成的，自动渲染就会失效
        //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();
        table.render();
    });
</script>

<!-----------------------分割线-->
<script th:inline="javascript">
    var myName = [[${session.mingzi}]];
    //alert(myName);

    var currentPage = 1;//当前页码
    var pageSize =10;//每页显示的数据量
    var totalCount = 0;//总条数
    var totalPage = 1;//总页码
    //console.log(1111111)
    //加载分页信息
    /*var myName=[[${session.mingzi}]];
    alert(myName);*/

    function pageInfos() {
        //清空


        $(".table-page").find("tr:gt(0) td").html("&nbsp;");
        $(".table-page").find("tr:even(2)").css({"background-color": "#F5F5F5"});
        //$(".table-page").find("tr:odd(1)").css({"background-color": "#A9A9A9"});

        reName = $("#reName").val();
        posname = $("#posname").val();
        workEx = $("#workEx").val();
        resState = $("#resState").val();
        checkTime = $("#checkTime").val();
        let jsonA = {
            currentPage: currentPage,
            pageSize: pageSize,
            reName1: reName,
            posname: posname,
            workEx: workEx,
            resState: resState,
            checkTime: checkTime
        };
        //console.log(jsonA)

        $.ajaxSettings.async = false;


        $.getJSON("/resume/aLists", jsonA, function (data) {
            console.log(data)
            totalPage = data.pages;
            // console.log(totalPage)
            totalCount=data.total;
            //解析集合里面的数据，注意.list
            $(data.list).each(function (i, j) {
                // $(".table-page").find("tr").eq(i + 1).find("td").eq(0).text((currentPage - 1) * pageSize + (i + 1));'"+j.resState.eq(1)+"' selected="selected" t
                $(".table-page").find("tr").eq(i + 1).find("td").eq(0).text(j.reName1);
                $(".table-page").find("tr").eq(i + 1).find("td").eq(1).text(j.reSex);
                $(".table-page").find("tr").eq(i + 1).find("td").eq(2).text(j.schoolTag);
                $(".table-page").find("tr").eq(i + 1).find("td").eq(3).text(j.education);
                $(".table-page").find("tr").eq(i + 1).find("td").eq(4).text(j.major);
                $(".table-page").find("tr").eq(i + 1).find("td").eq(5).html("<input type='text' value='" + j.position.posName + "' class='layui-input a6'>");
                $(".table-page").find("tr").eq(i + 1).find("td").eq(6).text(j.workEx);
                $(".table-page").find("tr").eq(i + 1).find("td").eq(7).text(j.checkTime);


                if (j.resState == "存档") {
                    //$(".table-page").find("tr").eq(i + 1).find("td").eq(8).find("").attr("disabled", disabled);

                    $(".table-page").find("tr").eq(i + 1).find("td").eq(8).html("<select style='width: 100px;height: 33px;border: none;padding-left: 5px;'  name='resStates' id='resStates' onchange='gaibian(this," + j.id + ")'>" +
                        "<option  value='存档' >存档</option>" +
                        "<option  value='推荐面试'>推荐面试</option>" +
                        "<option value='推荐二面' readonly='readonly'>推荐二面</option>" +
                        "<option value='推荐三面' readonly='readonly'>推荐三面</option>" +
                        "<option value='建议录用' readonly='readonly'>建议录用</option>" +
                        "<option value='录用' readonly='readonly'>录用</option>" +
                        "<option value='删除'>删除</option>"
                        + "</select>");


                } else {
                    $(".table-page").find("tr").eq(i + 1).find("td").eq(8).html("<select style='width: 100px;height: 33px;border: none;padding-left: 5px;'  name='resStates' id='resStates' onchange='gaibian(this," + j.id + ")' disabled>" +
                        "<option  value='存档' >存档</option>" +
                        "<option  value='推荐面试'>推荐面试</option>" +
                        "<option value='推荐二面' >推荐二面</option>" +
                        "<option value='推荐三面' >推荐三面</option>" +
                        "<option value='建议录用' >建议录用</option>" +
                        "<option value='录用' >录用</option>" +
                        "<option value='删除'>删除</option>"
                        + "</select>");
                }
                $(".table-page").find("tr").eq(i + 1).find("td").eq(8).find("option[value='" + j.resState + "']").attr("selected", true);

                $(".table-page").find("tr").eq(i + 1).find("td").eq(9).html("<button type='button' class='layui-btn'><a style='color: white' href='/resume/xiugaicha/" + j.id + "'>修改</a></button>&nbsp;&nbsp;&nbsp;&nbsp;<button  type='button' class='layui-btn layui-btn-normal'><a style='color: white' href='/resume/chakantiaos/" + j.id + "'>明细</a></button>&nbsp;&nbsp;&nbsp;&nbsp;" +
                    "<button type='button' class='layui-btn layui-btn-warm'><a style='color: white' href='#' onclick='shanchu(" + j.id + ")' id='ahref'>删除</a></button>");
            });


        })

        $.ajaxSettings.async = true;

        shoupage()
    }


    function shoupage() {
        //  $(".page").text(currentPage + "/" + totalPage);
        if (totalPage == 0 || totalPage < 0) {
            $(".pagess").text(1 + "/" + 1);
        } else {
            $(".pagess").text(currentPage + "/" + totalPage);
        }
    }


    //下一页
    function next() {

        currentPage++;
        console.log(currentPage);
        if (currentPage > totalPage) {
            currentPage = totalPage;
            return;
        }
        pageInfos()

    }


    //上一页
    function prev() {
        currentPage--;
        console.log(currentPage);
        if (currentPage < 1) {
            currentPage = 1;
            return;
        }
        pageInfos()
    }

    //首页
    function start() {

        currentPage = 1;
        pageInfos()


    }

    //尾页
    function end() {
        currentPage = totalPage;
        pageInfos()
    }

    function selPro() {
        //防治出现2/1的情况
        currentPage = 1;

        //筛选总条数
        totalCount;

        //分页查看数据
        pageInfos();
        //以下判断防治出现“"0数据", 出现1/0的情况， 收尾工作
        if (totalCount == 0) {
            totalPage = 1;
            $(".page").text(currentPage + "/" + totalPage);
            //alert("抱歉，未找到符合条件的数据！");
        }
    };


    function gaibian(thisA, id) {
        var resStates = $(thisA).val();
        //console.log("111111111111"+resStates);

        //获取当前日期
        let myDate = new Date();
        var year = myDate.getFullYear();        //获取当前年
        //console.log(year)
        var month = myDate.getMonth() + 1;   //获取当前月
        //console.log(month)
        var date = myDate.getDate();//获取当前日
        //console.log(date)
        //console.log("1111111111111111"+myDate);
        let nows = year + "-" + month + "-" + date;//拼接 yyyy-mm-dd
        //console.log(nows);


        //if (resStates=="存档"){
        if (resStates == "推荐面试") {


            layui.use("layer", function () {
                var layer = layui.layer;
                //layer.msg("大家好，这是一个弹层", { time: 9000, type: 1,title:['测试一下','font-size:18px'] });
                //$("#resStates").change(function() {

                layer.open({
                    title: "推荐面试意见",
                    type: 1,
                    area: ['800px', '400px'],
                    content: "<div  id='test2' style='height: 300px; width: 700px;margin: 0 auto;' ><table border='0' class='layui-form a61 '  ><tr>" +
                        "<td>推荐人:&nbsp;&nbsp;&nbsp;&nbsp;</td><td><input type='text' id='referrers' class='layui-input'  style='background-color: #d0d0d0; width: 90%' value='" + myName + "'  readonly></td><td>推荐时间:&nbsp;&nbsp;&nbsp;&nbsp;</td><td><input type='text' id='recommendTimes' class='layui-input' style='background-color: #d0d0d0;width: 90%' value='" + nows + "' readonly></td></tr>" +
                        "<tr><td>&nbsp;</td></tr><tr><td>推荐面试意见:&nbsp;&nbsp;&nbsp;&nbsp;</td><td colspan='3'><textarea placeholder='请输入内容' class='layui-input' id='opinions' style='width: 96%;height: 190px; background-color: #d0d0d0;padding: 10px '></textarea></td></tr></table> </div>",
                    btn: ["确定", "取消"],
                    btnAlign: 'c',
                    skin: 'layui-layer-molv',
                    //"<div style='margin-top: 40px'><button class='layui-btn' style='margin-left: 255px'>确定</button><button class='layui-btn' style='margin-left: 100px'>返回</button></div>   "+${session.mingzi}+"
                    btn1: function () {
                        var referrer = $("#referrers").val();
                        var recommendTime = $("#recommendTimes").val();
                        var opinion = $("#opinions").val();
                        let jsonS = {
                            id: id,
                            referrer: referrer,
                            recommendTime: recommendTime,
                            opinion: opinion
                        }

                        console.log(jsonS);
                        $.getJSON("/resume/xuigai_03", jsonS, function (dataE) {
                            console.log(dataE)
                            if (dataE > 0) {
                                alert("修改成功")
                            } else {
                                alert("修改失败")
                            }
                        })
                    }

                });
                //});
            });
            // }


        } else if (resStates == "推荐二面" || resStates == "推荐三面" || resStates == "建议录用" || resStates == "录用") {

            layui.use("layer", function () {
                var layer = layui.layer;
                //layer.msg("大家好，这是一个弹层", { time: 9000, type: 1,title:['测试一下','font-size:18px'] });

                layer.msg('您不能修改简历状态', {
                    icon: 2
                });

            });
        } else if (resStates == "删除") {
            //layui.use("layui",function() {
            //var layui=layui.layer;
            $.ajaxSettings.async = false;
            layer.confirm('您确定删除吗?', {
                btn: ['确定', '取消'],
                btn1: function () {
                    let jsonw = {
                        id: id,
                        resState: "删除"
                    }

                    $.getJSON("/resume/shanchu", jsonw, function (dataW) {
                        if (dataW > 0) {
                            location.href = "/resume/h4"
                            alert("删除成功！！！")
                        } else {
                            alert("删除失败！！！")
                        }
                    })

                }
            },)
            $.ajaxSettings.async = true;
            //})
        }

    }

    function shanchu(id) {

        // var texts=$("ahref").text();

        /*let jsonA = {
            id: id,
            resState: '删除'
        }*/


        $.ajaxSettings.async = false;
        layer.confirm('您确定删除吗?', {
            btn: ['确定', '取消'],
            btn1: function () {
                let jsonJ = {
                    id: id,
                    resState: "删除"
                }

                $.getJSON("/resume/shanchu", jsonJ, function (dataJ) {
                    if (dataJ > 0) {
                        alert("删除成功！！！")
                        location.href = "/resume/h4"
                    } else {
                        alert("删除失败！！！")
                    }
                })

            }
        },)
        $.ajaxSettings.async = true;


        //console.log(jsonA)

    }
</script>

<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#checkTime' //指定元素
            , type: 'date'
        });
    });
</script>
</html>